package com.jin.core.configuration;

import com.jin.core.interceptors.PermissionInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//用来注册写好的Interceptors
@Configuration
public class InterceptionConfiguration implements WebMvcConfigurer {

    @Bean
    //通过这种方式把PermissionInterceptor加入到ioc,可能与外面的那个不是同一个
    public HandlerInterceptor getPermissionInterceptor(){
        return new PermissionInterceptor();
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(this.getPermissionInterceptor());
    }
}
